home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94b.txt
/
000063_icon-group-sender _Wed Sep 21 09:12:45 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1995-02-09
|
2KB
Received: by cheltenham.cs.arizona.edu; Wed, 21 Sep 1994 04:36:08 MST
Message-Id: <9409210805.AA06761@eithne.aldiscon.ie>
From: Simon Chapman <simonc@aldiscon.ie>
Subject: Re: Question: conjunction in Icon and C
To: Art Eschenlauer <eschen@molbio.cbs.umn.edu>
Date: Wed, 21 Sep 1994 09:12:45 +0100 (BST)
Cc: icon-group@cs.arizona.edu
In-Reply-To: <9409202041.AA18914@molbio.cbs.umn.edu> from "Art Eschenlauer" at Sep 20, 94 03:41:27 pm
X-Mailer: ELM [version 2.4 PL23]
Content-Type: text
Content-Length: 1212
Errors-To: icon-group-errors@cs.arizona.edu
Art Eschenlauer scribbles:
>
> I have a C question that Icon'ers are more likely to understand than the
> average run-of-the-mill C programmer, so here goes.
I'm sure that C programmers would actually be better, but anyhow ....
>
> In Icon, if I say:
> if <expr1> & <expr2> then <expr3> else <expr4>
> and <expr1> fails, <expr2> will not be evaluated.
>
> In C, if I say:
> if ( <expr1> && <expr2> ) <expr3>; else <expr4>;
> and <expr1> has a value of zero (NULL, etc.), is it defined (in the ANSI
> standard, I guess) whether <expr2> will be evaluated or is this compiler
> specific?
>
Looking at my Que C Quick Reference and ANSI K & R, the two logical
operators && and || are subject to what the former calls
"Short Circuit Evaluation" which does as you say, namely if
<expr1> evaluates to 0, <expr2> will NOT be evaluated. Both operators
guaranteed left to right evaluation.
--
+-------------------------------------------------+
| Aldiscon Ltd., | simon chapman |
| Hambleden House, | simonc@aldiscon.ie |
| Lwr. Pembroke St., | Ph.: +353.1.6053183 direct |
| Dublin 2, Ireland. | (incl. Voice mail ) |
+-------------------------------------------------+